<template>
  <a-card :bordered="false">
    <div style="display: flex; justify-content: space-between">
      <!-- 操作按钮区域 -->
      <div class="table-operator">
        <!-- <a-button @click="handleAdd" type="primary" icon="plus" v-has="'serverInfo:add'">新增</a-button> -->
        <!--<a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl"
        @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
        <a-dropdown v-if="selectedRowKeys.length > 0">
          <a-menu slot="overlay">
            <a-menu-item key="1" @click="batchDel"
              ><a-icon type="delete" v-has="'serverInfo:delete'" />删除</a-menu-item
            >
          </a-menu>
          <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
        </a-dropdown>
      </div>
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper" style="display: flex; justify-content: end">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="7" :md="8" :sm="24" >
              <a-form-item label="城市服务商" style="margin-right: 10px">
                <serveSelect @selectClick="selectClick" :value="queryParam.agencyCode"></serveSelect>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="广告商ID" style="margin-right: 10px">
                <a-input placeholder="请输入广告商ID" v-model="queryParam.advertiserId"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="开始时间">
                <a-date-picker v-model="queryParam.startTime" :valueFormat="'YYYY-MM-DD'" @change="startChange" />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="结束时间">
                <a-date-picker
                  v-model="queryParam.endTime"
                  :valueFormat="'YYYY-MM-DD'"
                  @change="endChange"
                  :disabled-date="disabledDate"
                />
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin: 0 8px">重置</a-button>
<!--                <a-button type="primary" icon="download" @click="handleExportXls('服务表')">导出</a-button>-->
                <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a> -->
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </div>


    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="1"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
        autoHeight
      >
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <!-- <xhdjServerInfo-modal ref="modalForm" @ok="modalFormOk"></xhdjServerInfo-modal> -->
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { getFileAccessHttpUrl, getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import serveSelect from '@/components/serveSelect.vue'

export default {
  name: 'xhdjStatisticAdvertiserList',
  mixins: [JeecgListMixin],
  components: {
    serveSelect
  },
  data () {
    return {
      description: '服务表管理页面',
      // 表头
      columns: [
        {
          title: '时间',
          align: 'center',
          width: 60,
          dataIndex: 'time'
        },
        {
          title: '扫码已注册用户',
          align: 'center',
          dataIndex: 'scanRegUserCount'
        },

        {
          title: '扫码用户',
          align: 'center',
          dataIndex: 'scanUserCount'
        }

        // {
        //   title: '操作',
        //   dataIndex: 'action',
        //   align: 'center',
        //   scopedSlots: { customRender: 'action' },
        // },
      ],
      url: {
        list: '/sys/advertiser/wydjAdvertiser/dayList',
        delete: '/xhdjServerInfo/delete',
        deleteBatch: '/deleteBatch',
        exportXlsUrl: '/finance/sysxhdjFundsLog/dayListExport',
        importExcelUrl: 'xhdjServerInfo/importExcel',
        init: '/sys/advertiser/wydjAdvertiser/statisticsDay'
      }
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },

  methods: {
    getAvatarView: function (avatar) {
      return getFileAccessHttpUrl(avatar)
    },
    selectClick (value) {
      this.queryParam.agencyCode = value
      this.searchQuery()
    },
    startChange (value) {
      if (value) {
        this.queryParam.startTime = value + ' 00:00:00'
      } else {
        this.queryParam.startTime = value
      }
    },
    endChange (value) {
      if (value) {
        this.queryParam.endTime = value + ' 23:59:59'
      } else {
        this.queryParam.endTime = value
      }
    },
    disabledDate (time) {
      return new Date(time).getTime() < new Date(this.queryParam.startTime).getTime()
    },
    init () {
      getAction(this.url.init, this.queryParam).then(res => {
        if (res.code == 200) {
          res.result.map(res => {
            res.time = '合计'
          })
          this.dataSource.push(...res.result)
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
